package com.example.demo.job;

import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.Trigger;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 合同检查
 *
 * <p>
 * 如果待生效的合同到了合同的开始时间，将其调整为生效中
 * 如果生效中的合同到了合同的截止日期，将其调整为已到期
 * </p>
 *
 * @author 叮当猫的百宝箱
 * @version 1.0
 * @since 2024-08-27
 */
@Slf4j
public class ContractInspectJob implements Job {

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        LocalDateTime now = LocalDateTime.now();
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
        dateTimeFormatter.format(now);

        Trigger trigger = jobExecutionContext.getTrigger();
        String name = trigger.getKey().getName();
        log.debug("Contract Inspect Job: {} Trigger Name {}  ", dateTimeFormatter.format(now), name);
    }
}
